/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;

import alcatelparser.modules.AlgoUtil;
import alcatelparser.modules.BuilderFactory;
import alcatelparser.modules.I;

/**
 *
 * @author geniuz
 */
public class AdditionalParticipantInfoTag extends DefaultParserTag
{

    public AdditionalParticipantInfoTag()
    {
    }

    public final void parseTag(int ai[], int i)
    {
        _array = ai;
        int j = AlgoUtil.getLength(ai, i + 1);
        _startParsePosition = i;
        setStandartLength(ai, i);
        /*
        if(isFullForm())
            BuilderFactory.getBuilder().writeTagContent(3, 0, getTagPropertiesValue(I.I(6474)), getTagIdentifyContent(i, i + 1));
        int j1;
        for(int k = 0; k < j; k += j1)
        {
            int l = i + 2 + k;
            int i1 = _array[l];
            if(toHex(i1).equals(I.I(5536)))
                j1 = parsePhysicalLineCode(l);
            else
                j1 = parseReceivedDigits(l);
        }*/

    }

    private int parseReceivedDigits(int i)
    {
        int j = AlgoUtil.getLength(_array, i + 1);
        if(isFullForm())
        {
            String s = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(getHexStringContent(i + 2, j)).toString();
            BuilderFactory.getBuilder().writeTagContent(4, 0, getTagPropertiesValue(I.I(2203)), s);
            PhoneNumberDecoratorTag phonenumberdecoratortag1 = new PhoneNumberDecoratorTag();
            phonenumberdecoratortag1.decorateTag(_array, i, false, j);
        } else
        if(isTagChecked(I.I(2188)))
            if(!isFieldsDecoding())
            {
                BuilderFactory.getBuilder().writeTagContent(1, 0, getReducedTagPropertiesValue(I.I(2203)), getHexStringContent(i + 2, j));
            } else
            {
                PhoneNumberDecoratorTag phonenumberdecoratortag = new PhoneNumberDecoratorTag();
                phonenumberdecoratortag.setReducedTagName(getReducedTagPropertiesValue(I.I(2203)));
                phonenumberdecoratortag.decorateTag(_array, i, false, j);
            }
        return j + 2;
    }

    private int parsePhysicalLineCode(int i)
    {
        int j = AlgoUtil.getLength(_array, i + 1);
        String s = getHexStringContent(i + 2, j);
        String s1 = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(s).toString();
        if(isFullForm())
        {
            BuilderFactory.getBuilder().writeTagContent(4, 0, getTagPropertiesValue(I.I(2142)), s1);
            s1 = (new StringBuilder()).append(I.I(5979)).append(s.substring(0, 4)).append(I.I(539)).append(s.substring(4)).toString();
            BuilderFactory.getBuilder().writeTagContent(9, 1, "", s1);
        } else
        if(isTagChecked(I.I(2125)))
        {
            String s2 = isFieldsDecoding() ? (new StringBuilder()).append(s.substring(0, 4)).append(I.I(539)).append(s.substring(4)).toString() : s;
            BuilderFactory.getBuilder().writeTagContent(1, 0, getReducedTagPropertiesValue(I.I(2142)), s2);
        }
        return j + 2;
    }

    public final String getParseIdentityTag()
    {
        return I.I(6471);
    }
}
